package com.homwee.tvap.common.comSettingInterface;


import com.mediatek.twoworlds.factory.MtkTvFApiDisplay;
import com.mediatek.twoworlds.factory.MtkTvFApiSystem;
import com.mediatek.twoworlds.factory.model.MtkTvFApiMiuSysSscInfo;

import android.content.Context;
import android.util.Log;



//factory page6 
public class factoryPage6{
	static String TAG ="factory6"; 

	static factoryPage6 Interface =null;
	MtkTvFApiDisplay mMtkTvFApiDisplay=null;
	MtkTvFApiSystem mMtkTvFApiSystem=null;
	
	
	private factoryPage6(Context context){
		try {

			mMtkTvFApiDisplay=MtkTvFApiDisplay.getInstance();
			mMtkTvFApiSystem=MtkTvFApiSystem.getInstance();
		} catch (Exception e) {
			// TODO: handle exception
			Log.v("tv","miscManager ==null");
		}
	} 
	
	public static factoryPage6 getInstance(Context context){
		if(Interface ==null){
			Interface = new factoryPage6(context);
		}
		return Interface;
	}
		
	@SuppressWarnings("deprecation")
	public int getLVDSSSC(){
		int LVDSSSC =0;
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			LVDSSSC =mTvMiscManager.getLvdsSscStep();
			Log.v("tv","getLVDSSSC ="+LVDSSSC);
		}*/
		return LVDSSSC;
	}
	
	@SuppressWarnings("deprecation")
	public int getMEMSSC(){
		int MEMSSC =0;
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			MEMSSC =mTvMiscManager.getMemsscStep();
			Log.v("tv","getMEMSSC ="+MEMSSC);
		}*/
		return MEMSSC;
	}
	
	@SuppressWarnings("deprecation")
	public int getLVDSLevel(){
		int LVDSLevel =0;
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			LVDSLevel =mTvMiscManager.getLvdsSscSpan();
			Log.v("tv","getLVDSLevel ="+LVDSLevel);
		}*/

		return LVDSLevel;
	}	
	
	@SuppressWarnings("deprecation")
	public void setLVDSSSC(int value){
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			mTvMiscManager.setLvdsSscStep(value);
			Log.v("tv","setLVDSSSC ="+value);
		}*/
		
	}
	
	@SuppressWarnings("deprecation")
	public void setMEMSSC(int value){
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			mTvMiscManager.setMemsscStep(value);
			Log.v("tv","setMEMSSC ="+value);
		}*/
	}
	
	@SuppressWarnings("deprecation")
	public void setLVDSLevel(int value){
		/*//zcj 2018-10-30if(mTvMiscManager !=null){
			mTvMiscManager.setLvdsSscSpan(value);
			Log.v("tv","setLVDSLevel"+value);
		}*/
	}

	public int getLvdsSSCEnable() {
		// TODO Auto-generated method stub
		Log.d("zcj", ((mMtkTvFApiDisplay.getLVDSenable()?1:0)+""));
		return mMtkTvFApiDisplay.getLVDSenable()?1:0;
		//return 1;
	}

	public void setLvdsSSCEnable(int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setLvdsSSCEnable ="+value);
		mMtkTvFApiDisplay.setLVDSenable(value==1?true:false);
	}

	public int getLvdsSSCSpan() {
		// TODO Auto-generated method stub
		//int LvdsSSCSpan =mTvMiscManager.getLvdsSscSpan();
		int LvdsSSCSpan=0;
		LvdsSSCSpan =mMtkTvFApiDisplay.getLVDSmodulation();
		Log.v("tv","getLvdsSSCSpan ="+LvdsSSCSpan);
		return LvdsSSCSpan;
	}

	public void setLvdsSSCSpan(int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setLvdsSSCSpan ="+value);
		mMtkTvFApiDisplay.setLVDSmodulation(value);
	}

	public int getLvdsSSCStep() {
		// TODO Auto-generated method stub
		int LvdsSSCStep =0;
		LvdsSSCStep =mMtkTvFApiDisplay.getLVDSpercentage();
		Log.v("tv","LvdsSSCStep ="+LvdsSSCStep);
		return LvdsSSCStep;
		
	}

	public void setLvdsSSCStep(int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setLvdsSSCStep ="+value);
		mMtkTvFApiDisplay.setLVDSpercentage(value);
	}

	public int getMIUEnable(int index) {
		// TODO Auto-generated method stub
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		boolean miuEnable=sscInfo.enable;
		//boolean miuEnable=false;
		Log.v("tv","miuEnable ="+miuEnable);
		return miuEnable?1:0;
	}
	
	public MtkTvFApiMiuSysSscInfo getMIUInfo(int index) {
		// TODO Auto-generated method stub
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		return sscInfo;
	}
	
	public void setMIUEnable(int index,int value) {
		// TODO Auto-generated method stub
		Log.v("tv","MIUEnable ="+value);
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		boolean miuEnable=(value==1?true:false);
		mMtkTvFApiSystem.setMiuSsc((byte)index, sscInfo.freq, sscInfo.ratio, miuEnable);
		
	}

	public int getMIUModulation(int index) {
		// TODO Auto-generated method stub
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		int miuModulation=sscInfo.freq;
		//int miuModulation=0;
		Log.v("tv","miuModulation ="+miuModulation);
		return miuModulation;
	}

	public void setMIUModulation(int index,int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setMIUModulation ="+value);
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		mMtkTvFApiSystem.setMiuSsc((byte)index, (short) value, sscInfo.ratio, sscInfo.enable);
	}

	public int getMIUPercentage(int index) {
		// TODO Auto-generated method stub
		int miuPercentage=0;
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		miuPercentage=sscInfo.ratio;
		Log.v("tv","miuPercentage ="+miuPercentage);
		return miuPercentage;
	}

	public void setMIUPercentage(int index,int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setMemSSCStep ="+value);
		MtkTvFApiMiuSysSscInfo sscInfo=mMtkTvFApiSystem.getMiuSsc((byte)index);
		mMtkTvFApiSystem.setMiuSsc((byte)index, sscInfo.freq, (short) value, sscInfo.enable);
	}
	
	public int getLvdsSWing() {
		// TODO Auto-generated method stub
		//zcj 2018-10-30 int LvdsSscSwing =mTvMiscManager.getLvdsSscSwing();
		int lvdsSscSwing=0;
		lvdsSscSwing=mMtkTvFApiDisplay.getSwingLevel();
		Log.v("tv","getLvdsSscSwing ="+lvdsSscSwing);
		return lvdsSscSwing;
	}
	public void setLvdsSWing(int value) {
		// TODO Auto-generated method stub
		Log.v("tv","setLVDSSWing ="+value);
		mMtkTvFApiDisplay.setSwingLevel(value);
	}
	
	public void setUrsaLvdsSscEnable(boolean benable){
		//zcj 2018-10-30 mTvMiscManager.setUrsaLvdsSscEnable(benable);
	}
	public void setUrsaLvdsSscSpan(int value){
		//zcj 2018-10-30 mTvMiscManager.setUrsaLvdsSscSpan(value);
    }
	public void setUrsaLvdsSscStep(int value){
		//zcj 2018-10-30 mTvMiscManager.setUrsaLvdsSscStep(value);
    }
	public void setUrsaLvdsSscLevel(int value){
		//zcj 2018-10-30 mTvMiscManager.setUrsaLvdsSscLevel(value);
    }
	public boolean getUrsaLvdsSscEnable(){
		//zcj 2018-10-30 return mTvMiscManager.getUrsaLvdsSscEnable();
		return false;
    }
	public int getUrsaLvdsSscSpan(){
		//zcj 2018-10-30 return mTvMiscManager.getUrsaLvdsSscSpan();
		return 0;
	}
	public int getUrsaLvdsSscStep(){
		//zcj 2018-10-30 return mTvMiscManager.getUrsaLvdsSscStep();
		return 0;
    }
	public int getUrsaLvdsSscLevel(){
		//zcj 2018-10-30 return mTvMiscManager.getUrsaLvdsSscLevel();
		return 0;
    }
}